<template>
	<view class="quanb">
		<view class="tou">
			<view class="beij">
				<image src="../../static/zhengshu/41878.png" mode=""></image>
			</view>
			<view class="ner">
				<view class="keiti erkiaj">
					<view class="jin">
						余额
					</view>
					<view class="qian">
						{{userInfo.balance}}
					</view>
				</view>
				<view class="tixian">
					<view class="y" @click="dianjia">
						余额提现
					</view>
				</view>
			</view>
		</view>
		<view class="jilu">
			收益记录
		</view>
		<view class="liebiao">
			<view class="quab">
				<view class="biaot">
					<view class="yu yi">
						状态
					</view>
					<view class="yu er">
						变动金额
					</view>
					<view class="yu si">
						日期
					</view>
				</view>

			</view>
			<view class="neira" v-if="news.length === 0">
				<!-- 内容 -->
				暂无提现记录!!!
			</view>
			<view class="neir" v-for="item in news" :key="item.id">
				<view class="ayu ayi">
					<text>{{ item.publisherIncome > 0 ? '收益' : '提现' }}</text>
				</view>
				<view class="ayu aer">
					{{item.publisherIncome}}
				</view>

				<view class="ayu asi">
					{{item.createTime}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getIncome,
		addWithdraw,
		loadDict
	} from '../../request/api.js'
	export default {
		data() {
			return {
				userInfo: {},
				news: [],
				total: '',
				pageNo: 1,
				shou: false,
				jinge: '',
				ger: '',
				jinr: '',
				dianjiflag: true,
				shouw: false,
				chonz: '',
				useerif: '',
				liebia: [],
				menkan: ""
			}
		},
		onReachBottom() {
			if (this.total <= this.news.length) {
				uni.showToast({
					title: '已加载全部数据',
					icon: "none"
				});
			} else {
				this.pageNo++;
				this.memberBalanceRecorPage()
			}
		},
		onLoad() {
			this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
			this.memberBalanceRecorPage()
			loadDict('withdraw_amount').then(res => {
				console.log('提现门槛1', res);
				this.menkan = res.result[0]
			})
		},
		onShow() {},
		methods: {

			dianjia() {
				let that = this
				if (that.userInfo.balance <= 0) {
					uni.showToast({
						title: '余额不足',
						icon: "none"
					})
					return
				}
				if (that.userInfo.balance < this.menkan.value * 1) {
					uni.showToast({
						title: this.menkan.label + this.menkan.value,
						icon: "none"
					})
					return
				}
				uni.showModal({
					title: '提现',
					content: '是否确认提现？',
					success: function(res) {
						if (res.confirm) {
							addWithdraw({
								type: 2,
								memberId: that.userInfo.id,
								amount: that.userInfo.balance
							}).then(data => {
								uni.showToast({
									title: data.message,
									icon: 'none'
								})
								setTimeout(() => {
									uni.navigateBack()
								}, 500)
								console.log(res);
							})
						} else if (res.cancel) {
							that.loading = false
						}
					}
				});

			},
			memberBalanceRecorPage() {
				getIncome({
					publisherId: this.userInfo.id,
					pageNo: this.pageNo
				}).then(res => {
					console.log(res);
					this.news = this.news.concat(res.result.records)
					this.total = res.result.total; //数据总条数
				})
			}
		},
	}
</script>

<style scoped lang="less">
	.qnba {
		position: absolute;
		top: 0;

		width: 100vw;
		height: 100vh;
		background: rgba(0, 0, 0, 0.2);
	}

	.yue {
		width: 602rpx;
		height: 300rpx;
		background: #fff;
		margin: 0 auto;
		margin-top: 300rpx;
		border-radius: 16rpx;
		// text-align: center;
		padding-top: 40rpx;
		box-sizing: border-box;


		.shurk {
			width: 400rpx;
			height: 100rpx;
			background: #e8e8e8;
			margin: 0 auto;
			border-radius: 50rpx;

			input {
				height: 100rpx;
				margin-left: 20rpx;

			}
		}

		.anniu {
			display: flex;
			margin-top: 55rpx;
			border-top: 1rpx solid #d6d1d6;

			.qui {
				width: 50%;
				height: 100rpx;
				border-right: 1rpx solid #d6d1d6;
				text-align: center;
				line-height: 100rpx;
			}

			.que {
				width: 50%;
				height: 100rpx;
				text-align: center;
				line-height: 100rpx;
			}
		}
	}

	.tou {
		position: relative;
		width: 702rpx;
		height: 240rpx;
		border-radius: 16rpx;
		margin: 0 auto;
		margin-top: 56rpx;
		padding-left: 32rpx;
		padding-top: 40rpx;
		box-sizing: border-box;

		.beij {
			position: absolute;
			top: 0;
			left: 0;
			z-index: -9;
			width: 702rpx;
			height: 240rpx;

			image {
				width: 702rpx;
				height: 240rpx;
			}
		}

		.ner {
			display: flex;
			justify-content: space-between;
			padding-right: 90rpx;

			.erkiaj {
				margin-right: 90rpx;
			}

			.keiti {
				.jin {

					font-weight: 400;
					font-size: 26rpx;
					color: #FFFFFF;

					font-style: normal;
					text-transform: none;
					margin-top: 30rpx;
					margin-bottom: 20rpx;
				}

				.qian {

					font-weight: 400;
					font-size: 48rpx;
					color: #FFFFFF;

					font-style: normal;
					text-transform: none;
					margin-top: 6rpx;
					margin-bottom: 20rpx;
				}

				.jian {
					width: 142rpx;
					height: 54rpx;
					background: #FFFFFF;
					border-radius: 16rpx 16rpx 16rpx 16rpx;

					font-weight: 400;
					font-size: 28rpx;
					color: #F8492E;
					line-height: 54rpx;
					text-align: center;
					font-style: normal;
					text-transform: none;
				}
			}

			.tixian {
				.y {
					width: 142rpx;
					height: 64rpx;
					background: #FFFFFF;
					border-radius: 16rpx 16rpx 16rpx 16rpx;
					margin-bottom: 30rpx;

					font-weight: 400;
					font-size: 28rpx;
					color: #333333;
					line-height: 64rpx;
					text-align: center;
					font-style: normal;
					text-transform: none;
					margin-top: 50rpx;
				}

				.ya {
					width: 142rpx;
					height: 64rpx;
					background: #FFFFFF;
					border-radius: 16rpx 16rpx 16rpx 16rpx;
					margin-bottom: 30rpx;

					font-weight: 400;
					font-size: 28rpx;
					color: #333333;
					line-height: 64rpx;
					text-align: center;
					font-style: normal;
					text-transform: none;
				}
			}
		}
	}

	.jilu {
		width: 702rpx;
		margin: 0 auto;
		margin-top: 48rpx;
		margin-bottom: 21rpx;

		font-weight: 500;
		font-size: 36rpx;
		color: #333333;

		font-style: normal;
		text-transform: none;

	}

	.liebiao {
		width: 702rpx;
		margin: 0 auto;

		border-radius: 16rpx;
		border: 1rpx solid #EB333F;
		// border-right: 1rpx solid rgba(235, 51, 63, 0);
		border-left: 1rpx solid rgba(235, 51, 63, 0.2);

		border-right: 1rpx solid rgba(235, 51, 63, 0.2);
		border-bottom: 1rpx solid rgba(235, 51, 63, 0.2);


		.quab {
			width: 702rpx;
			background: rgba(235, 51, 63, 0.05);
			border-bottom: 1rpx solid #EB333F;

			.biaot {
				display: flex;
				height: 72rpx;
				align-items: center;
				justify-content: space-around;

				.yu {
					border-right: 1rpx solid #EB333F;
				}

				.yi {
					width: 154rpx;
					height: 72rpx;
					text-align: center;
					line-height: 72rpx;
					border-left: 1rpx solid #EB333F;
					border-radius: 16rpx 0rpx 0rpx 0rpx;
				}

				.er {
					width: 175rpx;
					height: 72rpx;
					text-align: center;
					line-height: 72rpx;
				}

				.sa {
					width: 136rpx;
					height: 72rpx;
					text-align: center;
					line-height: 72rpx;
				}

				.si {
					width: 372rpx;
					height: 72rpx;
					text-align: center;
					line-height: 72rpx;
					border-radius: 0rpx 16rpx 0rpx 0rpx;
					// border-right: 1rpx solid rgba(235, 51, 63, 0);
				}
			}


		}


	}

	.neira {
		text-align: center;
		margin: 40rpx 0;
	}

	.neir {
		display: flex;
		width: 702rpx;
		margin: 0 auto;
		// border-radius: 16rpx 16rpx 0rpx 0rpx;
		// border: 1rpx solid #EB333F;

		border-top: 1rpx solid rgba(235, 51, 63, 0.2);

		.ayu {
			border-right: 1rpx solid rgba(235, 51, 63, 0.2);
		}

		.ayi {
			width: 154rpx;
			height: 72rpx;
			text-align: center;
			line-height: 72rpx;
		}

		.aer {
			width: 175rpx;
			height: 72rpx;
			text-align: center;
			line-height: 72rpx;
		}

		.asa {
			width: 136rpx;
			height: 72rpx;
			text-align: center;
			line-height: 72rpx;
		}

		.asi {
			width: 372rpx;
			height: 72rpx;
			text-align: center;
			line-height: 72rpx;
			border-radius: 0rpx 16rpx 0rpx 0rpx;
			border-right: 1rpx solid rgba(235, 51, 63, 0);

		}
	}
</style>